﻿#pragma once
#include "zyObject.h"


namespace BlackMoonUI {
    class zyBase {
    protected:
        zyObject* m_obj;//zybase 下的第一个成员是 obj 的指针...  所以   &obj 指针  就是 zybase
        //getobj 取到的是obj 的指针,  其实就是一个 zybase  ... &一次 就变成了  zybase*
    public:
        zyBase();
        ~zyBase();

        zyObject* getObject(BOOL bAddRef = FALSE) const;
        zyObject* 取对象(BOOL 添加引用 = FALSE) const;

        BOOL setObject(zyObject* newObj, BOOL bAddRef = TRUE);
        BOOL 置对象(zyObject* 新对象, BOOL 添加引用 = TRUE);

        BOOL setHwnd(HWND hwnd);
        BOOL 置窗口句柄(HWND 窗口句柄);

        HWND getHwnd() const;
        HWND 取窗口句柄() const;

        int getBorder() const;
        void setBorder(int border);
        BOOL hasBorder() const;

        std::wstring getType() const;
        void setType(const std::wstring& type);

        std::wstring getName() const;
        void setName(const std::wstring& name);

        BOOL HasMember(const std::wstring& name);
        LONG_PTR GetMember(const std::wstring& name) const;
        void SetMember(const std::wstring& name, LONG_PTR border);

        void SetRegEvent(const std::wstring& name, TRegEvent* pRegEvent);
        TRegEvent* GetRegEvent(const std::wstring& name) const;

    protected:
        static void zyBase_Destroy(zyObject* obj);
        static void zyBase_OnNCDestroy(zyObject* obj);
        static LRESULT CALLBACK zyBase_WndProc(zyObject* obj, HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL* bHandled);
        static LRESULT CALLBACK zyBase_ChildWndProc(zyObject* obj, HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL* bHandled);
        static int GetFunKeyState();

    private:
        static BOOL SysHotKeyHandler(HWND hWnd, const std::wstring& className, wchar_t wchr);
    };

}
